home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / mail-tools / thor / thor_2.22 / thor.lha / rexx / CalcDl.thor < prev    next >
Text File  |  1995-12-18  |  3KB  |  96 lines

  1. /*
  2. ** CalcDl.thor 1.0 (19.5.95) Eirik Synnes
  3. **
  4. ** This script will calculate an estimate of the time needed to download
  5. ** files selected in Thor and present the results in a requester.  In
  6. ** order to do this the files will have to be present in Thor's file
  7. ** database.  It can be run either in the Startup Window or from inside a
  8. ** system.
  9. **
  10. ** Change the cpsrate variable below to whatever your modem is capable of.
  11. ** Suggested values are 3100 for 28.8k modems and 1500 for 14.4k modems.
  12. ** (a bit lower than the maximum rate to justify for poor phonelines and
  13. ** delays)
  14. **
  15. ** Please note that this won't work with files selected for ftp'ing with
  16. ** FTPGet.thor since these files are not added as events.
  17. **
  18. */
  19.  
  20. cpsrate = 3100
  21.  
  22. options results
  23.  
  24. /* Find Thor and BBSREAD ARexx ports' */
  25. p=address()||' '||show('P',,);if pos('THOR.',p)>0 then thorport=word(substr(p,pos('THOR.',p)),1);else do;say 'No THOR port found!';exit(0);end
  26. if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
  27.  
  28. totsize = 0; numfiles = 0; notfound = 0
  29.  
  30. address(thorport)
  31. CURRENTSYSTEM STEM curbbs
  32. if rc > 1 then do
  33.  REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
  34.  exit(0)
  35.  end
  36.  
  37. address(bbsread)
  38. GETBBSDATA BBSNAME '"'curbbs.BBSNAME'"' STEM bbsdata
  39. if rc ~= 0 then do 
  40.  REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  41.  exit(0)
  42.  end
  43.  
  44. if bbsdata.NUMEVENT > 0 then do event = bbsdata.FIRSTEVENT to bbsdata.LASTEVENT
  45.  READBREVENT BBSNAME '"'curbbs.BBSNAME'"' EVENTNR event TAGSSTEM evtag DATASTEM evdata
  46.  if rc ~= 0 then do
  47.   REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  48.   exit(0)
  49.   end
  50.  
  51.  if evdata.EVENTTYPE = 4 then do
  52.   if ~bittst(evdata.FLAGS, 0) & ~bittst(evdata.FLAGS, 2) & ~bittst(evdata.FLAGS, 3) & ~bittst(evdata.FLAGS, 5) then do
  53.    if evtag.DIRECTORY = 'EVTAG.DIRECTORY' then SEARCHBRFILE BBSNAME '"'curbbs.BBSNAME'"' STEM file SEARCH '"'evtag.FILENAME'"' NAME
  54.    else SEARCHBRFILE BBSNAME '"'curbbs.BBSNAME'"' STEM file FAREANAME '"'evtag.DIRECTORY'"' SEARCH '"'evtag.FILENAME'"' NAME
  55.    if rc ~= 0 then do
  56.     REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  57.     exit(0)
  58.     end
  59.    if result > 0 then do
  60.     READBRFILE BBSNAME '"'curbbs.BBSNAME'"' FAREANAME '"'file.FILEAREA.1'"' FILENR file.FILE.1.1 TAGSSTEM fltag
  61.     if rc ~= 0 then do
  62.      REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  63.      notfound = notfound + 1
  64.      end
  65.     else do
  66.      totsize = totsize + fltag.SIZE
  67.      numfiles = numfiles + 1
  68.      end
  69.     end
  70.    else notfound = notfound + 1
  71.    end
  72.   end
  73.  drop evtag. evdata. file.
  74.  end
  75.  
  76. address(thorport)
  77.  
  78. if totsize = 0 & notfound = 0 then do
  79.  REQUESTNOTIFY '"No active downloads on 'curbbs.BBSNAME'."' '"Ok"'
  80.  exit(0)
  81.  end
  82.  
  83. if totsize > 0 then do
  84.  xfertime = totsize / 8 * 9 / cpsrate
  85.  xfermin = trunc(xfertime / 60)
  86.  xfersec = trunc(xfertime // 60)
  87.  reqbody = 'Statistics on active downloads at 'curbbs.BBSNAME':\n'numfiles 'files counting 'totsize' bytes ('totsize/1024'kb).\nApprox. 'xfermin' minute(s) and 'xfersec' second(s) transfertime.'
  88.  if notfound > 0 then reqbody = reqbody'\n'notfound' file(s) were not found in the file database.'
  89.  end
  90. else do
  91.  if notfound > 0 then reqbody = 'None of the files were found in the file database.'
  92.  end
  93.  
  94. REQUESTNOTIFY '"'reqbody'"' '"Thanks"'
  95. exit(0)
  96.